package com.settlement.system.service.impl;

import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblAkcAdditionalItemDetailMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.TblAkcAdditionalItemDetail;
import com.settlement.system.service.ITblAkcAdditionalItemDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 爱库存-补款明细 服务实现类
 *
 * @author Ximi
 * @since 2020-07-06
 */
@Service
@Slf4j
public class TblAkcAdditionalItemDetailServiceImpl extends BaseServiceImpl implements ITblAkcAdditionalItemDetailService {

    @Resource
    private TblAkcAdditionalItemDetailMapper tblAkcAdditionalItemDetailMapper;

    @Override
    public BaseMapper init() {
        return tblAkcAdditionalItemDetailMapper;
    }

    @Override
    public TblAkcAdditionalItemDetail getFoot(Map<String, Object> params) throws ServiceException {
        try {
            return tblAkcAdditionalItemDetailMapper.getFoot(params);
        } catch (Exception ex) {
            log.error("获取合计异常", ex);
            throw new ServiceException("获取合计异常", ex);
        }
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void batchUpdateExtractMoneyDate(List<TblAkcAdditionalItemDetail> list) throws ServiceException {
        try {
            for (TblAkcAdditionalItemDetail detail : list) {
                tblAkcAdditionalItemDetailMapper.updateExtractMoneyDate(detail);
            }
        } catch (Exception ex) {
            throw new ServiceException("批量更新异常",ex);
        }
    }

    @Override
    public int selectCountExistExtractMoneyDateByExchangeOrderNo(List<TblAkcAdditionalItemDetail> list) throws ServiceException {
        try {
            return tblAkcAdditionalItemDetailMapper.selectCountExistExtractMoneyDateByExchangeOrderNo(list);
        } catch (Exception ex) {
            throw new ServiceException("查询提现日期不为空的交易订单号的条数异常",ex);
        }
    }


}

